package test.enumTest;

public enum OrderStatusEnum implements BaseEnum{

    // orderStatus <--> status
    ORDER_STATUS_INITIAL("INITIAL", "FAILED"),
    ORDER_STATUS_WAIT2PAY("WAIT2PAY", "LOOP"),
    ORDER_STATUS_CLOSED("CLOSED", "FAILED"),
    ORDER_STATUS_WAIT2DELIVER("WAIT2DELIVER", "LOOP"),
    ORDER_STATUS_DELIVERING("DELIVERING", "LOOP"),
    ORDER_STATUS_DELIVERY_FAILED("DELIVERY_FAILED", "FAILED"),
    ORDER_STATUS_PARTIAL_DELIVERY_SUCCESS("PARTIAL_DELIVERY_SUCCESS", "LOOP"),
    ORDER_STATUS_SUCCESS("SUCCESS", "SUCCESS");

    private String code;
    private String msg;


    private OrderStatusEnum(String orderStatus, String status) {
        this.code = orderStatus;
        this.msg = status;
    }

    public static String getStatusByOrderStatus(String orderStatus) {
        for (OrderStatusEnum e : OrderStatusEnum.values()) {
            if (e.getCode().equals(orderStatus)) {
                return e.getMsg();
            }
        }
        return null;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getMsg() {
        return msg;
    }
}
